#include <cstdio>
#define max(a,b) (a>b?a:b)
int f[301][301][9][9];
int n, m;
int log2(int x)  
{  
    int k=0;  
    while((1<<(k+1))<x)++k;  
    return k;  
}
void ST()  
{  
    int i,j,u,v,logn=log2(n),logm=log2(m);  
    for(u=0;u<=logn;++u)  
        for(v=0;v<=logm;++v)  
            if(u+v)for(i=1;i+(1<<u)-1<=n;++i)  
                for(j=1;j+(1<<v)-1<=m;++j)  
                if(v==0)f[i][j][u][v]=max(f[i][j][u-1][v],f[i+(1<<(u-1))][j][u-1][v]);  
                else f[i][j][u][v]=max(f[i][j][u][v-1],f[i][j+(1<<(v-1))][u][v-1]);  
}
int get(int r1,int c1,int r2,int c2)  
{  
    int k=log2(r2-r1+1),t=log2(c2-c1+1);  
    int a=max(f[r1][c1][k][t],f[r1][c2-(1<<t)+1][k][t]);  
    int b=max(f[r2-(1<<k)+1][c1][k][t],f[r2-(1<<k)+1][c2-(1<<t)+1][k][t]);  
    return max(a,b);  
}

void init( )
{
    int i, j;
    for ( i = 1; i <= n; i++ )
        for ( j = 1; j <= m; j++ )
            scanf("%d", &f[ i ][ j ][ 0 ][ 0 ]);
    ST( );
}

void work( )
{
    int q, r1, r2, c1, c2, p;
    scanf("%d", &q);
    while ( q-- )
    {
        scanf("%d%d%d%d", &r1 ,&c1, &r2, &c2);
        p = get( r1, c1, r2, c2 );
        printf("%d ", p);
        if ( f[ r1 ][ c1 ][ 0 ][ 0 ] == p || f[ r1 ][ c2 ][ 0 ][ 0 ] == p || f[ r2 ][ c1 ][ 0 ][ 0 ] == p || f[ r2 ][ c2 ][ 0 ][ 0 ] == p )
            puts("yes");
        else
            puts("no");
    }
}

int main( )
{
    while ( scanf("%d%d", &n, &m) != EOF )
    {
        init( );
        work( );
    }
    return 0;
}
